@@ -288,13 +288,16 @@ def pageviews_by_document(period, verbose=False):
288
288
289
289
for row in run_report (date_range , create_article_report_request , verbose = verbose ):
290
290
path = row .dimension_values [0 ].value
291
- num_page_views = int (row .metric_values [0 ].value )
292
- # The path is guaranteed to be a KB article path without any query parameters.
293
- # If the URL path for KB articles changes, we'll need to continue to support
294
- # the previous URL structure for a year -- the longest period of time we look
295
- # backwards -- as well as the new URL structure.
291
+ # The path should be a KB article path without any query parameters, but in reality
292
+ # we've seen that it can sometimes be "/". If the URL path for KB articles changes,
293
+ # we'll need to continue to support the previous URL structure for a year -- the
294
+ # longest period of time we look backwards -- as well as the new URL structure.
296
295
# Current URL structure: /{locale}/kb/{slug}
297
- locale , slug = path .strip ("/" ).split ("/kb/" )
296
+ try :
297
+ num_page_views = int (row .metric_values [0 ].value )
298
+ locale , slug = path .strip ("/" ).split ("/kb/" )
299
+ except ValueError :
300
+ continue
298
301
yield ((locale , slug ), num_page_views )
299
302
300
303
@@ -307,14 +310,18 @@ def pageviews_by_question(period=LAST_YEAR, verbose=False):
307
310
308
311
for row in run_report (date_range , create_question_report_request , verbose = verbose ):
309
312
path = row .dimension_values [0 ].value
310
- num_page_views = int (row .metric_values [0 ].value )
311
- # The path is guaranteed to be a question path without any query parameters.
312
- # If the URL path for questions changes, we'll need to continue to support
313
- # the previous URL structure for a year -- the longest period of time we look
314
- # backwards -- as well as the new URL structure.
313
+ # The path should be a question path without any query parameters, but in reality
314
+ # we've seen that it can sometimes be "/". If the URL path for questions changes,
315
+ # we'll need to continue to support the previous URL structure for a year -- the
316
+ # longest period of time we look backwards -- as well as the new URL structure.
315
317
# Current URL structure: /{locale}/questions/{question_id}
316
- locale , question_id = path .strip ("/" ).split ("/questions/" )
317
- yield (int (question_id ), num_page_views )
318
+ try :
319
+ num_page_views = int (row .metric_values [0 ].value )
320
+ locale , question_id = path .strip ("/" ).split ("/questions/" )
321
+ question_id = int (question_id )
322
+ except ValueError :
323
+ continue
324
+ yield (question_id , num_page_views )
318
325
319
326
320
327
def search_clicks_and_impressions (start_date , end_date , verbose = False ):
0 commit comments